import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import p02 from './p02';
import render from '@feidao/web/atom/browser/render/render';
import get_form_data from '@feidao/web/atom/browser/form/get-data';

export default async function a014(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	// fd.data.node.querySelector<HTMLAreaElement>('[data-feidao-id="fd-wh000006-003"]').innerHTML = '';
	// fd.data.node.querySelector<HTMLImageElement>('[data-feidao-id="fd-wh000006-005"]').src = '';
	// 获取属性，渲染p02
	const widgets = fd.data.node.querySelector<HTMLFormElement>('[name="widgets"]');
	const data = get_form_data(widgets);
	let attrs = '';
	for (const attr in data) {
		if (data.hasOwnProperty(attr)) {
			const v = data[attr];
			if (v === true) {
				attrs += attr + ' ';
			} else {
				if (v) {
					attrs += attr + '=\'' + v + '\' ';
				}
			}
		}
	}
	render(fd, attrs, p02, 'p02', 'inner');

	const a = fd.data.node.querySelector<HTMLAreaElement>('[data-feidao-id="fd-wh000006-002"]');
	a.innerHTML = `
<fd-wh000006 data-feidao-id="fd-wh000006-001" style="width:500px;height:400px;margin-right:20px;display:inline-block;" ${attrs}></fd-wh000006>
	`;

}
